﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Management.Automation;


namespace CitrixPVSWrapper
{
    public static class RegexDefs
    {
        public static string IpAddressRegex = @"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b";
        public static string MacAddressRegex = @"^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$";
    }

    // Query Definition Section. Required to pass all correct details to the query function
    public enum QueryActionType
    {
        Get,
        Info,
        Add,
        Set,
        SetList,
        Run,
        RunWithReturn,
        Remove
    }

    public class MCliReturnObject
    {
        public ReturnState ReturnState = ReturnState.NotExecuted;
        public System.Collections.ObjectModel.Collection<ErrorRecord> Errors = null;

        public MCliReturnObject(ReturnState ReturnState, System.Collections.ObjectModel.Collection<ErrorRecord> Errors)
        {
            this.ReturnState = ReturnState;
            this.Errors = Errors;
        }
    }

    public enum ReturnState
    {
        Success = 0,
        Error = 1,
        NotExecuted = 2
    }
    
    public class QueryDefinition
    {
        public QueryActionType Action;
        public string TargetObject;
        public System.Collections.Generic.List<string> Parameters = new System.Collections.Generic.List<string>();
        public System.Collections.Generic.List<string> RecordValues = new System.Collections.Generic.List<string>();
        public System.Collections.Hashtable InjectValues = new System.Collections.Hashtable();

        public QueryDefinition() { }

        public QueryDefinition(QueryActionType Action, string TargetObject)
        {
            this.Action = Action;
            this.TargetObject = TargetObject;
        }

        public QueryDefinition(QueryActionType Action, string TargetObject, List<string> Parameters)
        {
            this.Action = Action;
            this.TargetObject = TargetObject;
            this.Parameters = Parameters;
        }

        public QueryDefinition(QueryActionType Action, string TargetObject, List<string> Parameters, List<string> RecordValues)
        {
            this.Action = Action;
            this.TargetObject = TargetObject;
            this.Parameters = Parameters;
            this.RecordValues = RecordValues;
        }

        public QueryDefinition(QueryActionType Action, string TargetObject, string Parameter)
        {
            this.Action = Action;
            this.TargetObject = TargetObject;
            this.Parameters.Add(Parameter);
        }

        public QueryDefinition(QueryActionType Action, string TargetObject,List<string> Parameters, Hashtable InjectValues)
        {
            this.Action = Action;
            this.TargetObject = TargetObject;
            this.Parameters = Parameters;
            this.InjectValues = InjectValues;
        }



    }

    // Global Enumerations Section - to save duplication of enums

    #region GlobalEnums

    public enum PvsSetListMode
    {
        Merge,
        Replace
    }

    public enum PvsDiskType
    {
        Maintenance = 1,
        Test = 2,
        Override = 3
    }

    public enum PvsLogLevel
    {
        None = 0,
        Fatal = 1,
        Error = 2,
        Warning = 3,
        Info = 4,
        Debug = 5,
        Trace = 6,
    }

    public enum PvsServerActive
    {
        Inactive = 0,
        Active = 1,
        Unknown = 2,
    }

    public enum PvsRamDiskInvitationType
    {
        Fixed = 0,
        Variable = 1,
    }

    public enum PvsDeviceBootFrom
    {
        vDisk = 1,
        HardDisk = 2,
        FloppyDisk = 3
    }

    public enum PvsDeviceAuthentication
    {
        None = 0,
        UserNamePassword = 1,
        External = 2
    }

    public enum PvsDeviceType
    {
        None = 0,
        TestDisks = 1,
        MaintenanceDisks = 2,
        PersonalVDisk = 3,
        PersonalVDiskTests = 4
    }

    public enum PvsDeviceDiskPrinterState
    {
        Disabled = 0,
        NetworkEnabled = 1,
        LocalEnabled = 2,
        Default = 3
    }

    public enum PvsDiskLicenseMode
    {
        None = 0,
        MultipleActivationKey = 1,
        KeyManagementService = 2
    }

    public enum PvsMakLicenseStatus
    {
        MakNotUsed = 0,
        NotActivated = 1,
        Activated = 2
    }

    public enum PvsDiskWriteCacheType
    {
        Private = 0,
        CacheOnServer = 1,
        CacheInDeviceRAM = 3,
        CacheOnDeviceHardDrive = 4,
        DeviceRAMDisk = 6,
        CacheOnServerPersistent = 7,
        CacheInDeviceRAMwithOverflowonHardDisk = 9
    }

    public enum PvsDiskState
    {
        UpToDate = 0,
        VersionFileMissing = 1,
        VersionFileOutOfDate = 2,
        PropertiesMissing = 3,
        PropertiesOutOfDate = 4,
        ServerUnreachable = 5
    }

    public enum PvsDiskActive
    {
        Active = 1,
        Unknown = 2,
        Other = 0
    }

    public enum PvsSubnetAffinity
    {
        None = 0,
        BestEffort = 1,
        Fixed = 2
    }

    public enum PvsDiskVersionType
    {
        Base = 0,
        Manual = 1,
        Automatic = 2,
        Merge = 3,
        MergedBase = 4
    }

    public enum PvsDiskVersionAccess
    {
        Production = 0,
        Maintenance = 1,
        MaintenanceHighestVersion = 2,
        Override = 3,
        Merge = 4,
        MergeMaintenance = 5,
        MergeTest = 6,
        Test = 7
    }

    public enum PvsFarmMergeMode
    {
        Production = 0,
        Test = 1,
        Maintenance = 2,
    }

    public enum PvsServerState
    {
        Down = 0,
        Up = 1,
        Unknown = 2,
    }

    public enum PvsLicenseType
    {
        None = 0,
        Desktop = 1,
        Server = 2,
        OemSmartClient = 5,
        XenApp = 6,
        XenDesktop = 7
    }

    public enum PvsDeviceLicense
    {
        None = 0,
        Desktop1 = 1,
        Desktop2 = 2
    }

    public enum PvsVersionType
    {
        Normal = 0,
        OROM = 1,
        Secure = 2
    }

    public enum PvsVirtualHostingType
    {
        CitrixXenserver = 0,
        MicrosoftHyperV = 1,
        VmWareESXi = 2
    }

    public enum PvsUpdateApproval
    {
        Production = 0,
        Test = 1,
        Maintenance = 2,
    }

    public enum PvsTaskRecurrence
    {
        None = 0,
        Daily = 1,
        Weekdays = 2,
        Weekly = 3,
        MonthlyDate = 4,
        MonthlyType = 5
    }

    public enum PvsTaskDayMask
    {
        Monday = 1,
        Tuesday = 2,
        Wednesday = 4,
        Thursday = 8,
        Friday = 16,
        Saturday = 32,
        Sunday = 64,
        AllDays = 128
    }

    public enum PvsTaskMonthlyOffset
    {
        None = 0,
        First = 1,
        Second = 2,
        Third = 3,
        Fourth = 4,
        Last = 5
    }

    public enum PvsDiskStatus
    {
        Valid = 0,
        MissingPropertiesFile = 1,
        AccessDenied = 2,
        AccessDeniedMissingProperties = 3,
        InvalidDiskFile = 4,
        ManifestMissingOrInvalid = 5
    }

    public enum PvsTaskState
    {
        Processing = 0,
        Cancelled = 1,
        Complete = 2
    }

    public enum PvsUpdateStatus
    {
        Ready = 0,
        UpdatePending = 1,
        PreparingImage = 2,
        StartingVm = 3,
        UpdateInProgress = 4,
        StoppingVm = 5,
        SubmittingImage = 6,
        RevertingImage = 7,
        Invalid = 8,
        Aborted = 9,
        CompletedSuccessfully = 10,
        NoUpdates = 11
    }

    public enum PvsAuditType
    {
        Many = 0,
        AuthGroup = 1,
        Collection = 2,
        Device = 3,
        Disk = 4,
        DiskLocator = 5,
        Farm = 6,
        FarmView = 7,
        Server = 8,
        Site = 9,
        SiteView = 10,
        Store = 11,
        System = 12,
        UserGroup = 13
    }

    public enum PvsAuditAction
    {
        AddAuthGroup = 1,
        AddCollection = 2,
        AddDevice = 3,
        AddDiskLocator = 4,
        AddFarmView = 5,
        AddServer = 6,
        AddSite = 7,
        AddSiteView = 8,
        AddStore = 9,
        AddUserGroup = 10,
        AddVirtualHostingPool = 11,
        AddUpdateTask = 12,
        AddDiskUpdateDevice = 13,
        DeleteAuthGroup = 1001,
        DeleteCollection = 1002,
        DeleteDevice = 1003,
        DeleteDeviceDiskCacheFile = 1004,
        DeleteDiskLocator = 1005,
        DeleteFarmView = 1006,
        DeleteServer = 1007,
        DeleteServerStore = 1008,
        DeleteSite = 1009,
        DeleteSiteView = 1010,
        DeleteStore = 1011,
        DeleteUserGroup = 1012,
        DeleteVirtualHostingPool = 1013,
        DeleteUpdateTask = 1014,
        DeleteDiskUpdateDevice = 1015,
        DeleteDiskVersion = 1016,
        RunAddDeviceToDomain = 2001,
        RunApplyAutoUpdate = 2002,
        RunApplyIncrementalUpdate = 2003,
        RunArchiveAuditTrail = 2004,
        RunAssignAuthGroup = 2005,
        RunAssignDevice = 2006,
        RunAssignDiskLocator = 2007,
        RunAssignServer = 2008,
        RunWithReturnBoot = 2009,
        RunCopyPasteDevice = 2010,
        RunCopyPasteDisk = 2011,
        RunCopyPasteServer = 2012,
        RunCreateDirectory = 2013,
        RunCreateDiskCancel = 2014,
        RunDisableCollection = 2015,
        RunDisableDevice = 2016,
        RunDisableDeviceDiskLocator = 2017,
        RunDisableDiskLocator = 2018,
        RunDisableUserGroup = 2019,
        RunDisableUserGroupDiskLocator = 2020,
        RunWithReturnDisplayMessage = 2021,
        RunEnableCollection = 2022,
        RunEnableDevice = 2023,
        RunEnableDeviceDiskLocator = 2024,
        RunEnableDiskLocator = 2025,
        RunEnableUserGroup = 2026,
        RunEnableUserGroupDiskLocator = 2027,
        RunExportOemLicenses = 2028,
        RunImportDatabase = 2029,
        RunImportDevices = 2030,
        RunImportOemLicenses = 2031,
        RunMarkDown = 2032,
        RunWithReturnReboot = 2033,
        RunRemoveAuthGroup = 2034,
        RunRemoveDevice = 2035,
        RunRemoveDeviceFromDomain = 2036,
        RunRemoveDirectory = 2037,
        RunRemoveDiskLocator = 2038,
        RunResetDeviceForDomain = 2039,
        RunResetDatabaseConnection = 2040,
        RunRestartStreamingService = 2041,
        RunWithReturnShutdown = 2042,
        RunStartStreamingService = 2043,
        RunStopStreamingService = 2044,
        RunUnlockAllDisk = 2045,
        RunUnlockDisk = 2046,
        RunServerStoreVolumeAccess = 2047,
        RunServerStoreVolumeMode = 2048,
        RunMergeDisk = 2049,
        RunRevertDiskVersion = 2050,
        RunPromoteDiskVersion = 2051,
        RunCancelDiskMaintenance = 2052,
        RunActivateDevice = 2053,
        RunAddDiskVersion = 2054,
        RunExportDisk = 2055,
        RunAssignDisk = 2056,
        RunRemoveDisk = 2057,
        RunDiskUpdateStart = 2057,
        RunDiskUpdateCancel = 2057,
        RunSetOverrideVersion = 2058,
        RunCancelTask = 2059,
        RunClearTask = 2060,
        RunWithReturnCreateDisk = 3001,
        RunWithReturnCreateDiskStatus = 3002,
        RunWithReturnMapDisk = 3003,
        RunWithReturnRebalanceDevices = 3004,
        RunWithReturnCreateMaintenanceVersion = 3005,
        RunWithReturnImportDisk = 3006,
        RunByteArrayInputImportDevices = 4001,
        RunByteArrayInputImportOemLicenses = 4002,
        RunByteArrayOutputArchiveAuditTrail = 5001,
        RunByteArrayOutputExportOemLicenses = 5002,
        SetAuthGroup = 6001,
        SetCollection = 6002,
        SetDevice = 6003,
        SetDisk = 6004,
        SetDiskLocator = 6005,
        SetFarm = 6006,
        SetFarmView = 6007,
        SetServer = 6008,
        SetServerBiosBootstrap = 6009,
        SetServerBootstrap = 6010,
        SetServerStore = 6011,
        SetSite = 6012,
        SetSiteView = 6013,
        SetStore = 6014,
        SetUserGroup = 6015,
        SetVirtualHostingPool = 6016,
        SetUpdateTask = 6017,
        SetDiskUpdateDevice = 6018,
        SetListDeviceBootstraps = 7001,
        SetListDeviceBootstrapsDelete = 7002,
        SetListDeviceBootstrapsAdd = 7003,
        SetListDeviceCustomProperty = 7004,
        SetListDeviceCustomPropertyDelete = 7005,
        SetListDeviceCustomPropertyAdd = 7006,
        SetListDeviceDiskPrinters = 7007,
        SetListDeviceDiskPrintersDelete = 7008,
        SetListDeviceDiskPrintersAdd = 7009,
        SetListDevicePersonality = 7010,
        SetListDevicePersonalityDelete = 7011,
        SetListDevicePersonalityAdd = 7012,
        SetListDevicePortBlockerCategories = 7013,
        SetListDevicePortBlockerCategoriesDelete = 7014,
        SetListDevicePortBlockerCategoriesAdd = 7015,
        SetListDevicePortBlockerOverrides = 7016,
        SetListDevicePortBlockerOverridesDelete = 7017,
        SetListDevicePortBlockerOverridesAdd = 7018,
        SetListDiskLocatorCustomProperty = 7019,
        SetListDiskLocatorCustomPropertyDelete = 7020,
        SetListDiskLocatorCustomPropertyAdd = 7021,
        SetListDiskLocatorPortBlockerCategories = 7022,
        SetListDiskLocatorPortBlockerCategoriesDelete = 7023,
        SetListDiskLocatorPortBlockerCategoriesAdd = 7024,
        SetListDiskLocatorPortBlockerOverrides = 7025,
        SetListDiskLocatorPortBlockerOverridesDelete = 7026,
        SetListDiskLocatorPortBlockerOverridesAdd = 7027,
        SetListServerCustomProperty = 7028,
        SetListServerCustomPropertyDelete = 7029,
        SetListServerCustomPropertyAdd = 7030,
        SetListUserGroupCustomProperty = 7031,
        SetListUserGroupCustomPropertyDelete = 7032,
        SetListUserGroupCustomPropertyAdd = 7033
    }

    public enum PvsAuditAttachments
    {
        None = 0,
        Children = 1,
        Sibling = 2,
        Parameters = 4,
        Properties = 8
    }

    #endregion

    public struct PvsAdDomain
    {
        public string Name;
    }

    public struct PvsAuditActionParameter
    {
        public string AuditParameterName;
        public string Value;
    }

    public struct PvsAuditActionProperty
    {
        public string AuditPropertyName;
        public string OldValue;
        public string NewValue;
    }

    public struct PvsAuditActionSibling
    {
        public string AuditActionId;
        public PvsAuditType Type;
        public string ObjectId;
        public string ObjectName;
        public string Path;
        public string SiteId;
        public string SubId;
    }

    public struct PvsAuditTrail
    {
        public string AuditActionId;
        public System.DateTime Time;
        public string Username;
        public string Domain;
        public PvsAuditType Type;
        public PvsAuditAction Action;
        public string ObjectId;
        public string ObjectName;
        public string Path;
        public string SiteId;
        public string SubId;
        public string ParentId;
        public string rootId;
        public PvsAuditAttachments Attachments;
    }

    public struct PvsAuthGroup
    {
        public string AuthGroupId;
        public string AuthGroupName;
        public string Description;
        public string Role;
    }

    public struct PvsAuthGroupUsage
    {
        public string AuthGroupId;
        public string Id;
        public string Name;
        public string Role;
    }

    public struct PvsCollection
    {
        public string CollectionId;
        public string CollectionName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public string TemplateDeviceId;
        public string TemplateDeviceName;
        public System.UInt32 LastAutoAddDeviceNumber;
        public System.Boolean Enabled;
        public System.UInt32 DeviceCount;
        public System.UInt32 DeviceWithPvdCount;
        public System.UInt32 ActiveDeviceCount;
        public System.UInt32 MakActivateNeededCount;
        public string AutoAddPrefix;
        public string AutoAddSuffix;
        public System.Boolean AutoAddZeroFill;
        public System.UInt32 AutoAddNumberLength;
        public string Role;
    }

    public struct PvsDevice
    {
        public string DeviceId;
        public string DeviceName;
        public string CollectionId;
        public string CollectionName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public string DeviceMac;
        public PvsDeviceBootFrom BootFrom;
        public string ClassName;
        public System.UInt32 Port;
        public System.Boolean Enabled;
        public System.Boolean LocalDiskEnabled;
        public string Role;
        public PvsDeviceAuthentication Authentication;
        public string User;
        public string Password;
        public System.Boolean Active;
        public System.Boolean Template;
        public string AdTimeStamp;
        public string AdSignature;
        public PvsLogLevel LogLevel;
        public string DomainName;
        public string DomainObjectSid;
        public string DomainControllerName;
        public System.DateTime DomainTimeCreated;
        public PvsDeviceType Type;
        public string PvdDriveLetter;
        public System.UInt32 LocalWriteCacheSize;
        public System.Boolean BdmBoot;
        public string VirtualHostingPoolId;
    }

    public struct PvsDeviceBootstrap
    {
        public string DeviceId;
        public string Bootstrap;
        public string MenuText;
    }

    public struct PvsDeviceCustomProperty
    {
        public string DeviceId;
        public string Name;
        public string Value;
    }

    public struct PvsDeviceDiskPrinter
    {
        public string Name;
        public PvsDeviceDiskPrinterState State;
        public string DeviceId;
        public string DiskLocatorId;
    }

    public struct PvsDeviceInfo
    {
        public string DeviceId;
        public string DeviceName;
        public string CollectionId;
        public string CollectionName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public string DeviceMac;
        public PvsDeviceBootFrom BootFrom;
        public string ClassName;
        public System.UInt32 Port;
        public System.Boolean Enabled;
        public System.Boolean LocalDiskEnabled;
        public string Role;
        public PvsDeviceAuthentication Authentication;
        public string User;
        public string Password;
        public System.Boolean Active;
        public System.Boolean Template;
        public string AdTimeStamp;
        public string AdSignature;
        public PvsLogLevel LogLevel;
        public string DomainName;
        public string DomainObjectSid;
        public string DomainControllerName;
        public System.DateTime DomainTimeCreated;
        public PvsDeviceType Type;
        public string PvdDriveLetter;
        public System.UInt32 LocalWriteCacheSize;
        public System.Boolean BdmBoot;
        public string VirtualHostingPoolId;
        public string Ip;
        public System.UInt32 ServerPortConnection;
        public string ServerIpConnection;
        public string ServerId;
        public string ServerName;
        public string DiskLocatorId;
        public string DiskLocatorName;
        public System.UInt32 DiskVersion;
        public PvsDiskVersionAccess DiskVersionAccess;
        public string DiskFileName;
        public string Status;
        public PvsLicenseType LicenseType;
        public PvsMakLicenseStatus makLicenseActivated;
        public string Model;
        public PvsDeviceLicense License;
    }

    public struct PvsDevicePersonality
    {
        public string DeviceId;
        public string Name;
        public string Value;
    }

    public struct PvsDeviceStatus
    {
        public string DeviceId;
        public string DeviceName;
        public string Ip;
        public System.UInt32 ServerPortConnection;
        public string ServerIpConnection;
        public string ServerId;
        public string ServerName;
        public string DiskLocatorId;
        public string DiskLocatorName;
        public System.UInt32 DiskVersion;
        public PvsDiskVersionAccess DiskVersionAccess;
        public string DiskFileName;
        public string Status;
        public PvsLicenseType LicenseType;
        public PvsMakLicenseStatus makLicenseActivated;
    }

    public struct PvsDisk
    {
        public string DiskLocatorId;
        public string Class;
        public string ImageType;
        public System.UInt64 DiskSize;
        public System.UInt32 VHDBlockSize;
        public System.UInt32 WriteCacheSize;
        public System.Boolean AutoUpdateEnabled;
        public System.Boolean ActivationDateEnabled;
        public System.Boolean ADPasswordEnabled;
        public System.Boolean HAEnabled;
        public System.Boolean PrinterManagementEnabled;
        public PvsDiskWriteCacheType WriteCacheType;
        public PvsDiskLicenseMode LicenseMode;
        public System.DateTime ActiveDate;
        public string LongDescription;
        public string SerialNumber;
        public string Date;
        public string Author;
        public string Title;
        public string Company;
        public string InternalName;
        public string OriginalFile;
        public string HardwareTarget;
        public System.UInt64 MajorRelease;
        public System.UInt64 MinorRelease;
        public System.UInt64 Build;
    }

    public struct PvsDiskInfo
    {
        public string DiskLocatorId;
        public string DiskLocatorName;
        public string SiteId;
        public string SiteName;
        public string StoreId;
        public string StoreName;
        public string Description;
        public string MenuText;
        public string ServerId;
        public string ServerName;
        public System.Boolean enabled;
        public string Role;
        public System.Boolean Mapped;
        public System.Boolean EnabledForDevice;
        public System.Boolean Active;
        public System.Boolean RebalanceEnabled;
        public System.UInt32 RebalanceTriggerPercent;
        public PvsSubnetAffinity SubnetAffinity;
        public string DiskUpdateDeviceId;
        public string DiskUpdateDeviceName;
        public string Class;
        public string ImageType;
        public System.UInt64 DiskSize;
        public System.UInt32 VHDBlockSize;
        public System.UInt32 WriteCacheSize;
        public System.Boolean AutoUpdateEnabled;
        public System.Boolean ActivationDateEnabled;
        public System.Boolean AdPasswordEnabled;
        public System.Boolean HaEnabled;
        public System.Boolean PrinterManagementEnabled;
        public PvsDiskWriteCacheType WriteCacheType;
        public PvsDiskLicenseMode LicenseMode;
        public System.DateTime ActiveDate;
        public string LongDescription;
        public string SerialNumber;
        public string Date;
        public string Author;
        public string Title;
        public string Company;
        public string InternalName;
        public string OriginalFile;
        public string HardwareTarget;
        public System.UInt64 MajorRelease;
        public System.UInt64 MinorRelease;
        public System.UInt64 Build;
        public System.UInt32 DeviceCount;
        public System.Boolean Locked;
    }

    public struct PvsDiskInventory
    {
        public string DiskLocatorId;
        public System.UInt32 Version;
        public string ServerID;
        public string ServerName;
        public string FilePath;
        public System.DateTime FileTime;
        public System.DateTime PropertiesTime;
        public PvsDiskState State;
        public PvsDiskActive Active;
    }

    public struct PvsDiskLocator
    {
        public string DiskLocatorId;
        public string DiskLocatorName;
        public string SiteId;
        public string SiteName;
        public string StoreID;
        public string StoreName;
        public string Description;
        public string MenuText;
        public string ServerId;
        public string ServerName;
        public System.Boolean Enabled;
        public string Role;
        public System.Boolean Mapped;
        public System.Boolean EnabledForDevice;
        public System.Boolean Active;
        public System.Boolean RebalanceEnabled;
        public System.UInt32 RebalanceTriggerPercent;
        public PvsSubnetAffinity SubnetAffinity;
        public string DiskUpdateDeviceID;
        public string DiskUpdateDeviceName;
    }

    public struct PvsDiskLocatorCustomProperty
    {
        public string DiskLocatorId;
        public string Name;
        public string Value;
    }

    public struct PvsDiskLocatorLock
    {
        public string DiskLocatorId;
        public System.Boolean Exclusive;
        public string DeviceId;
        public string DeviceName;
        public string ServerId;
        public string ServerName;
        public System.Boolean ReadOnly;
    }

    public struct PvsDiskPrinter
    {
        public string DiskLocatorId;
        public string Name;
        public System.Boolean Network;
    }

    public struct PvsDiskVersion
    {
        public string DiskLocatorId;
        public System.UInt32 Version;
        public string Description;
        public PvsDiskVersionType Type;
        public System.DateTime CreateDate;
        public System.DateTime ScheduledDate;
        public System.Boolean DeleteWhenFree;
        public PvsDiskVersionAccess Access;
        public string DiskFileName;
        public System.UInt32 DeviceCount;
        public System.Boolean GoodInventoryStatus;
        public string TaskId;
        public System.Boolean CanDelete;
        public System.Boolean CanMerge;
        public System.Boolean CanMergeBase;
        public System.Boolean CanPromote;
        public System.Boolean CanRevertTest;
        public System.Boolean CanRevertMaintenance;
        public System.Boolean CanSetScheduledDate;
        public System.Boolean CanOverride;
        public System.Boolean IsPending;
    }

    public struct PvsDiskUpdateDevice
    {
        public string DeviceId;
        public string DeviceName;
        public string VirtualHostingPoolId;
        public string VirtualHostingPoolName;
        public string DiskLocatorId;
        public string DiskLocatorName;
        public string SiteId;
        public string SiteName;
        public string StoreId;
        public string StoreName;
        public string Description;
        public string DeviceMac;
        public System.UInt32 Port;
        public System.Boolean Active;
        public string AdTimeStamp;
        public string AdSignature;
        public PvsLogLevel LogLevel;
        public string DomainName;
        public string DomainObjectSid;
        public string DomainControllerName;
        public System.DateTime DomainTimeCreated;
        public string Ip;
        public System.UInt32 ServerPortConnection;
        public string ServerIpConnection;
        public string ServerId;
        public string ServerName;
        public System.UInt32 DiskVersion;
        public string Status;
        public PvsLicenseType LicenseType;
        public PvsMakLicenseStatus makLicenseActivated;
        public string Model;
        public PvsDeviceLicense License;
    }

    public struct PvsDiskUpdateStatus
    {
        public string DiskupdateTaskId;
        public string UpdateTaskId;
        public string UpdateTaskName;
        public string Description;
        public string DiskLocatorId;
        public string DiskLocatorName;
        public string VirtualHostingPoolId;
        public string VirtualHostingPoolName;
        public string DeviceId;
        public string DeviceName;
        public string SiteId;
        public string SiteName;
        public string StoreId;
        public string StoreName;
        public PvsUpdateStatus PreviousResult;
        public string PreviousResultMessage;
        public PvsUpdateStatus CurrentStatus;
        public string CurrentStatusMessage;
    }

    public struct PvsFarm
    {
        public string FarmId;
        public string FarmName;
        public string Description;
        public System.Boolean AutoAddEnabled;
        public System.Boolean AuditingEnabled;
        public System.DateTime LastAuditArchiveDate;
        public string DefaultSiteId;
        public string DefaultSiteName;
        public System.Boolean OfflineDatabaseSupportEnabled;
        public System.Boolean AdGroupsEnabled;
        public string LicenseServer;
        public System.UInt32 LicenseServerPort;
        public System.Boolean AutomaticMergeEnabled;
        public System.UInt32 MaxVersions;
        public PvsFarmMergeMode MergeMode;
        public string DatabaseServerName;
        public string DatabaseInstanceName;
        public string DatabaseName;
        public string FailoverPartnerServername;
        public string FailoverPartnerInstanceName;
        public string Role;
    }

    public struct PvsFarmView
    {
        public string FarmViewId;
        public string FarmViewName;
        public string Description;
        public System.UInt32 DeviceCount;
        public System.UInt32 ActiveDeviceCount;
        public System.UInt32 MakActivateNeededCount;
    }

    public struct PvsGroup
    {
        public string Name;
    }

    public struct PvsMapiErrorCode
    {
        public string ErrorCode;
        public string ErrorDescription;
    }

    public struct PvsNewVersionDisk
    {
        public string Name;
        public PvsDiskStatus Status;
        public string ServerId;
        public string StoreId;
    }

    public struct PvsServer
    {
        public string ServerId;
        public string ServerName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public System.UInt32 AdMaxPasswordAge;
        public System.UInt32 LicenseTimeout;
        public System.UInt32 VDiskCreatePacing;
        public System.UInt32 FirstPort;
        public System.UInt32 LastPort;
        public System.UInt32 ThreadsPerPort;
        public System.UInt32 BuffersPerThread;
        public System.UInt32 ServerCacheTimeout;
        public System.UInt64 IoBurstSize;
        public System.UInt32 MaxTransmissionUnits;
        public System.UInt32 MaxBootDevicesAllowed;
        public System.UInt32 MaxBootSeconds;
        public System.UInt32 BootPauseSeconds;
        public System.Boolean AdMaxPasswordAgeEnabled;
        public System.Boolean EventLoggingEnabled;
        public System.Boolean NonBlockingIoEnabled;
        public string Role;
        public System.Collections.Generic.List<string> Ip;
        public System.UInt32 InitialQueryConnectionPoolSize;
        public System.UInt32 InitialTransactionConnectionPoolSize;
        public System.UInt32 MaxQueryConnectionPoolSize;
        public System.UInt32 MaxTransactionConnectionPoolSize;
        public System.UInt32 RefreshInterval;
        public System.UInt32 UnusedDbConnectionTimeout;
        public System.UInt32 BusyDbConnectionRetryCount;
        public System.UInt32 BusyDbConnectionRetryInterval;
        public System.UInt32 LocalConcurrentIoLimit;
        public System.UInt32 RemoteConcurrentIoLimit;
        public string RamDiskIpAddress;
        public System.UInt32 RamDiskTimeToLive;
        public PvsRamDiskInvitationType RamDiskInvitationType;
        public System.UInt32 RamDiskInvitationPeriod;
        public PvsServerActive Active;
        public PvsLogLevel LogLevel;
        public System.UInt32 LogFileSizeMax;
        public System.UInt32 LogFileBackupCopiesMax;
        public System.UInt32 PowerRating;
        public string ServerFqdn;
        public string ManagementIp;
    }

    public struct PvsServerBiosBootstrap
    {
        public string ServerId;
        public string ServerName;
        public System.Boolean Enabled;
        public System.Boolean dhcpEnabled;
        public System.Boolean lookup;
        public System.Boolean VerboseMode;
        public System.Boolean InterruptSafeMode;
        public System.Boolean PaeMode;
        public System.Boolean BootFromHdOnFail;
        public System.UInt32 RecoveryTime;
        public System.UInt32 PollingTimeout;
        public System.UInt32 GeneralTimeout;
        public string BootServer1_Ip;
        public System.UInt32 BootServer1_Port;
        public string BootServer2_Ip;
        public System.UInt32 BootServer2_Port;
        public string BootServer3_Ip;
        public System.UInt32 BootServer3_Port;
        public string BootServer4_Ip;
        public System.UInt32 BootServer4_Port;
        public string Domain;
        public string DnsIpAddress1;
        public string DnsIpAddress2;
    }

    public struct PvsServerBootstrap
    {
        public string ServerId;
        public string BootServer1_Ip;
        public string BootServer1_Netmask;
        public string BootServer1_Gateway;
        public System.UInt32 BootServer1_Port;
        public string BootServer2_Ip;
        public string BootServer2_Netmask;
        public string BootServer2_Gateway;
        public System.UInt32 BootServer2_Port;
        public string BootServer3_Ip;
        public string BootServer3_Netmask;
        public string BootServer3_Gateway;
        public System.UInt32 BootServer3_Port;
        public string BootServer4_Ip;
        public string BootServer4_Netmask;
        public string BootServer4_Gateway;
        public System.UInt32 BootServer4_Port;
        public System.Boolean VerboseMode;
        public System.Boolean InterruptSafeMode;
        public System.Boolean PaeMode;
        public System.Boolean BootFromHdOnFail;
        public System.UInt32 RecoveryTime;
        public System.UInt32 PollingTimeout;
        public System.UInt32 GeneralTimeout;
    }

    public struct PvsServerBootstrapName
    {
        public string ServerId;
        public string Name;
    }

    public struct PvsServerCustomProperty
    {
        public string ServerId;
        public string Name;
        public string Value;
    }

    public struct PvsServerInfo
    {
        public string ServerId;
        public string ServerName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public System.UInt32 AdMaxPasswordAge;
        public System.UInt32 LicenseTimeout;
        public System.UInt32 VDiskCreatePacing;
        public System.UInt32 FirstPort;
        public System.UInt32 LastPort;
        public System.UInt32 ThreadsPerPort;
        public System.UInt32 BuffersPerThread;
        public System.UInt32 ServerCacheTimeout;
        public System.UInt64 IoBurstSize;
        public System.UInt32 MaxTransmissionUnits;
        public System.UInt32 MaxBootDevicesAllowed;
        public System.UInt32 MaxBootSeconds;
        public System.UInt32 BootPauseSeconds;
        public System.Boolean AdMaxPasswordAgeEnabled;
        public System.Boolean EventLoggingEnabled;
        public System.Boolean NonBlockingIoEnabled;
        public string Role;
        public System.Collections.Generic.List<string> Ip;
        public System.UInt32 InitialQueryConnectionPoolSize;
        public System.UInt32 InitialTransactionConnectionPoolSize;
        public System.UInt32 MaxQueryConnectionPoolSize;
        public System.UInt32 MaxTransactionConnectionPoolSize;
        public System.UInt32 RefreshInterval;
        public System.UInt32 UnusedDbConnectionTimeout;
        public System.UInt32 BusyDbConnectionRetryCount;
        public System.UInt32 BusyDbConnectionRetryInterval;
        public System.UInt32 LocalConcurrentIoLimit;
        public System.UInt32 RemoteConcurrentIoLimit;
        public string RamDiskIpAddress;
        public System.UInt32 RamDiskTimeToLive;
        public PvsRamDiskInvitationType RamDiskInvitationType;
        public System.UInt32 RamDiskInvitationPeriod;
        public PvsServerActive Active;
        public PvsLogLevel LogLevel;
        public System.UInt32 LogFileSizeMax;
        public System.UInt32 LogFileBackupCopiesMax;
        public System.UInt32 PowerRating;
        public string ServerFqdn;
        public string ManagementIp;
        public string ContactIp;
        public System.UInt32 ContactPort;
        public System.UInt32 DeviceCount;
    }

    public struct PvsServerStatus
    {
        public string ServerId;
        public string ServerName;
        public string Ip;
        public System.UInt32 Port;
        public System.UInt32 DeviceCount;
        public PvsServerState Status;
    }

    public struct PvsServerStore
    {
        public string StoreId;
        public string StoreName;
        public string ServerId;
        public string ServerName;
        public string Path;
        public string CachePath;
    }

    public struct PvsServiceAccountGroup
    {
        public string Name;
        public string Guid;
    }

    public struct PvsSite
    {
        public string SiteId;
        public string SiteName;
        public string Description;
        public string DefaultCollectionId;
        public string DefaultCollectionName;
        public System.UInt32 InventoryFilePollingInterval;
        public System.Boolean EnableDiskUpdate;
        public string DiskUpdateServerId;
        public string DiskUpdateServerName;
        public string MakUser;
        public string MakPassword;
        public string role;
    }

    public struct PvsSiteView
    {
        public string SiteViewId;
        public string SiteViewName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public System.UInt32 DeviceCount;
        public System.UInt32 DeviceWithPvdCount;
        public System.UInt32 ActiveDeviceCount;
        public System.UInt32 MakActivateNeededCount;
        public string role;
    }

    public struct PvsStore
    {
        public string StoreId;
        public string StoreName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public string Path;
        public System.Collections.Generic.List<string> CachePath;
        public string Role;
    }

    public struct PvsStoreSharedOrServerPath
    {
        public string StoreId;
        public string StoreName;
        public string SiteId;
        public string Path;
    }

    public struct PvsTask
    {
        public string TaskId;
        public string SiteId;
        public string SiteName;
        public string Handle;
        public string ServerFqdn;
        public string Ip;
        public System.UInt32 Port;
        public System.DateTime StartTime;
        public System.DateTime ExpirationTime;
        public PvsTaskState State;
        public string CommandType;
        public string Command;
        public string MapiException;
        public string Results;
    }

    public struct PvsUndefinedDisk
    {
        public string Name;
        public PvsDiskStatus Status;
        public string ServerId;
        public string StoreId;
    }

    public struct PvsUpdateTask
    {
        public string UpdateTaskId;
        public string UpdateTaskName;
        public string SiteId;
        public string SiteName;
        public string Description;
        public System.Boolean Enabled;
        public System.UInt32 Hour;
        public System.UInt32 Minute;
        public PvsTaskRecurrence Recurrence;
        public PvsTaskDayMask DayMask;
        public System.UInt32 Date;
        public PvsTaskMonthlyOffset MonthlyOffset;
        public string EsdType;
        public string PreUpdateScript;
        public string PreVmScript;
        public string PostUpdateScript;
        public string PostVmScript;
        public string Domain;
        public string OrganizationUnit;
        public PvsUpdateApproval PostUpdateApprove;
    }

    public struct PvsVirtualHostingPool
    {
        public string VirtualHostingPoolId;
        public string VirtualHostingPoolName;
        public string SiteId;
        public string SiteName;
        public PvsVirtualHostingType Type;
        public string Description;
        public string Server;
        public System.UInt32 Port;
        public string Datacenter;
        public System.UInt32 UpdateLimit;
        public System.UInt32 UpDateTimeout;
        public System.UInt32 ShutdownTimeout;
        public string Username;
        public string Password;
    }

    public struct PvsXdSite
    {
        public string XdSiteId;
        public System.Collections.Generic.List<string> ConfigServices;
    }

    public struct PvsVersion
    {
        public string MapiVersion;
        public System.UInt32 DbVersion;
        public PvsVersionType Type;
        public string DbEdition;
        public System.UInt32 DbSize;
    }
  
}
